*** Replication data for Hall and Shepsle (2013)

cd "~/Dropbox/Shepsle and Hall - Incumbency/Published"

use Hall_Shepsle, clear

ttest vote_share if maj==1 & u_g==0, by(R2) unequal

oneway vote_share R2

*** Table 1

reg vote_share R2 sen sen_r2 if maj==1 & u_g==0, cluster(name_id)

xtreg vote_share R2 sen sen_r2 if maj==1 & u_g==0, fe cluster(name_id)

gen win = vote_share > 50

probit win R2 sen sen_r2 if maj==1 & u_g==0 , cluster(name)


*** Table 2

reg vote_share R2 sen sen_r2 if maj==1 & u_g==0 & south==0, cluster(name_id)

xtreg vote_share R2 sen sen_r2 if maj==1 & u_g==0 & south==0, fe cluster(name_id)

*** Table 3

reg vote_share R2 sen sen_r2 if maj==0 & u_g==0, cluster(name_id)
outreg2 using "Table4.tex", tex replace label auto(2) dec(2)

reg vote_share R2 sen sen_r2 if maj==0 & u_g==0 & south==0, cluster(name_id)
outreg2 using "Table4.tex", tex append label auto(2) dec(2)

*** Table 4

use "Hall_Shepsle_placebo.dta", clear

areg vote_share R2 sen sen_r2 if chamber==9 & vote_share < 100 & inc==1 & maj==1 ///
, a(clust_state) cluster(clust_state)
outreg2 using "placebo.tex", tex replace label auto(2) dec(2)

areg vote_share R2 sen sen_r2 if chamber==8 & vote_share < 100 & inc==1 & maj==1 ///
, a(clust_state) cluster(clust_state)
outreg2 using "placebo.tex", tex append label auto(2) dec(2)

areg vote_share R2 sen sen_r2 if u_g==0 & inc==1 & office=="S" & maj==1, a(clust) cluster(clust)
outreg2 using "placebo.tex", tex append label auto(2) dec(2)


*** Table 5

use Hall_Shepsle, clear

reg vote_share minority sen sen_min if u_g==0, cluster(name_id)
outreg2 using "Table5.tex", tex replace label auto(2) dec(2)

reg vote_share minority sen sen_min if u_g==0 & R2==0, cluster(name_id)
outreg2 using "Table5.tex", tex append label auto(2) dec(2)

reg vote_share minority sen sen_min if u_g==0 & R2==1, cluster(name_id)
outreg2 using "Table5.tex", tex append label auto(2) dec(2)

*** Table 6

matrix B = J(6,5,.)
local count = 1
forvalues year_i = 1972(2)1980 {
	gen cutoff = year > `year_i'
	gen sen_cutoff = sen*cutoff
	reg vote_share cutoff sen sen_cutoff if maj==1 & u_g==0, cluster(name_id)
	matrix B[1,`count'] = _b[sen_cutoff]
	matrix B[2,`count'] = _se[sen_cutoff]
	xtreg vote_share cutoff sen sen_cutoff if maj==1 & u_g==0, fe cluster(name_id)
	matrix B[3,`count'] = _b[sen_cutoff]
	matrix B[4,`count'] = _se[sen_cutoff]
	reg vote_share cutoff sen sen_cutoff if maj==1, cluster(name_id)
	matrix B[5,`count'] = _b[sen_cutoff]
	matrix B[6,`count'] = _se[sen_cutoff]
	local count = `count' + 1
	drop cutoff
	drop sen_cutoff
}

matrix list B


*** Table 7

reg vote_share R2  sen sen_r2 dRbar7q  pres_match_econ pres_match if maj==1 & u_g==0, cluster(name)
outreg2 using "Table7.tex", tex replace label auto(2) dec(2)	

xtreg vote_share R2 sen sen_r2 dRbar7q  pres_match_econ pres_match if maj==1 & u_g==0, cluster(name)
outreg2 using "Table7.tex", tex append label auto(2) dec(2)



*** Appendix
use Hall_Shepsle, clear
sum vote_share sen dRbar7q

reg vote_share R2 sen sen_r2 if maj==1, cluster(name_id)
outreg2 using "supp1.tex", tex replace label auto(2) dec(2)	

xtreg vote_share R2 sen sen_r2 if maj==1, fe cluster(name_id)
outreg2 using "supp1.tex", tex append label auto(2) dec(2)	

gen log_sen = log(sen)
gen log_sen_r2 = log_sen*R2

reg vote_share R2 log_sen log_sen_r2 if maj==1, cluster(name_id)
outreg2 using "supp2.tex", tex replace label auto(2) dec(2)	

xtreg vote_share R2 log_sen log_sen_r2 if maj==1, fe cluster(name_id)
outreg2 using "supp2.tex", tex append label auto(2) dec(2)	

*** committee analysis

use Hall_Shepsle_committee, clear

areg vote_share R2 rank rank_R2 if u_g==0 & maj==1, a(name_clust) cluster(name_clust)
outreg2 using "committee.tex", tex replace label auto(2) dec(2)	
areg vote_share R2 rank rank_R2 if u_g==0 & maj==1 & south==0, a(name_clust) cluster(name_clust)
outreg2 using "committee.tex", tex append label auto(2) dec(2)	





